package viewmodel;

import model.Vocabulary;

import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.Sessions;

public class VocabDataVM {
	
	private VocabDataModel vocabData;
	
	public VocabDataVM(){
		vocabData = new VocabDataModel();
	}

	public VocabDataModel getVocabData() {
		return vocabData;
	}
	
	@Command
	@NotifyChange("vocabData")
	public void delVocab(@BindingParam("vocab") Vocabulary selectVocab){
		vocabData.removeVocab(selectVocab);
	}
	@Command
	public void gotoEdit(@BindingParam("vocab")Vocabulary selectVocab){
		Sessions.getCurrent().setAttribute("currentVocab", selectVocab);
		Executions.getCurrent().sendRedirect("vocab_layout_edit.jsp");
	}
}
